package com.cwz.logo;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

public class MainActivity extends Activity implements Receive {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		if(Util.hasInternet(this)){
			Toast.makeText(getApplicationContext(), "Loading...", Toast.LENGTH_SHORT).show();
		}else{
			Toast.makeText(getApplicationContext(), "This application needs internet connection!Please check your connection!", Toast.LENGTH_SHORT).show();
		}
		
		Gallery gallary = (Gallery) findViewById(R.id.gallery);
		gallary.setAdapter(null);
		
//		ListView list = (ListView) findViewById(R.id.listView);
//
//		ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
//		HashMap<String, Object> initmap = new HashMap<String, Object>();
//		// 初始载入页面
//		initmap.put("ItemImage", R.drawable.logo);
//		listItem.add(initmap);
//
//		// 覆盖SimpleAdapter的setViewImage方法，使之能够使用网络图片。
//		SimpleAdapter listItemAdapter = new SimpleAdapter(this, listItem,
//				R.layout.itemview, new String[] { "ItemImage" },
//				new int[] { R.id.ItemImage }) {
//			public void setViewImage(ImageView v, String value) {
//				if (value.startsWith("http")) {
//					Bitmap bitmap = Util.returnBitMap(value);
//					((ImageView) v).setImageBitmap(bitmap);
//				} else {
//					v.setImageResource(Integer.parseInt(value));
//				}
//			}
//		};
//		list.setAdapter(listItemAdapter);
//
//		GetDataThread thread = new GetDataThread(listItem, listItemAdapter,
//				this);
//		thread.start();
	}

	public void onReceived(Runnable runnable) {
		this.runOnUiThread(runnable);
	}

	

}